import jsonschema

from api.ihrmemploee import IhrmEmploeeApi
from common.DBUtil import DBUtil
from common.assert_util import common_assert


class TestIhrmEmploeeSelect:
    def setup(self):
        # 发送请求前，去库里添加一条员工数据，直接使用这条数据的id
        DBUtil.uid_db(
            "INSERT INTO bs_user(id,mobile,username,work_number) VALUES('3434343422','13909092121','lily','3444467362');")
    def teardown(self):
        DBUtil.uid_db(f"delete from bs_user where id='3434343422';")


    def test_ihrm_emploee_select(self):

        #发送请求
        resp=IhrmEmploeeApi.ihrm_emploee_select_api("3434343422")
        #断言
        # common_assert(resp,200,True,10000,"操作成功")
        #校验规则
        schema={
            "type":"object",
            "properties":{
                "success":{"const":True},
                "code":{"const":10000},
                "message":{"pattern":"操作成功"}
            },
            "required":["success","code","message","data"]
        }
        jsonschema.validate(instance=resp.json(),schema=schema)

